/**
 * @param {number} num
 * @return {number}
*/
var reverseBits = function(num) {
  let str = num.toString(2), result = 0;
  console.log(str);
  str = str.split("").reverse();
  console.log(str);
  for(let i = 0; i < str.length; i++) {
    result = result * 2 + str[i].charCodeAt() - '0'.charCodeAt();
  }
  return result;
};
let num = 1775;
console.log(reverseBits(num));
num = 7;
console.log(reverseBits(num));
